package com.xl6667.controller;

import com.xl6667.domain.ResponseResult;
import com.xl6667.domain.entity.Menu;
import com.xl6667.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/menu")
public class MenuController {
    @Autowired
    private MenuService menuService;

    /**
     * 获取所有菜单
     * @param menuName
     * @param status
     * @return
     */
    @GetMapping("/list")
    public ResponseResult getMenuList(String menuName, String status){
        return menuService.getMenuList(menuName,status);
    }
    /**
     * 添加菜单
     */

    @PostMapping
    public ResponseResult addMenu(@RequestBody Menu menu){
        return menuService.addMenu(menu);
    }
    /**
     * 获取菜单
     */
    @GetMapping("/{id}")
    public ResponseResult getMenu(@PathVariable Long id){
        return menuService.getMenu(id);
    }
    /**
     * 修改菜单
     */
    @PutMapping
    public ResponseResult putMenu(@RequestBody Menu menu){
        return menuService.putMenu(menu);
    }
    /**
     * 删除菜单
     */
    @DeleteMapping("{id}")
    public ResponseResult delMenu(@PathVariable Long id){
        return menuService.delMenu(id);
    }

    /**
     * 获取所有角色树
     * @return
     */
    @GetMapping("/treeselect")
    public ResponseResult getTreeselect(){
        return menuService.getTreeselect();
    }
    /**
     * 获取角色树
     */
    @GetMapping("roleMenuTreeselect/{id}")
    public ResponseResult getRoleMenuTreeselect(@PathVariable Long id){
        return menuService.getRoleMenuTreeselect(id);
    }

}
